Function Reference

_AD_GetUserPrimaryGroup

Returns the primary group the user is assigned to.

#Include <AD.au3>
_AD_GetUserPrimaryGroup([$sUser = @UserName])

 

Parameters

$sUser Optional: User for which the primary group is to be returned (default = @Username). Can be specified as Fully Qualified Domain Name (FQDN) or sAMAccountName

 

Return Value

Success: Primary group (FQDN) the user is assigned to.
Failure: "", sets @error to:
    1 - Specified user does not exist
    2 - A primary group couldn't be found for the specified user

 

Remarks

None.

 

Related

_AD_IsMemberOf, _AD_GetUserGroups, _AD_RecursiveGetMemberOf, _AD_SetUserPrimaryGroup

 

Example


#AutoIt3Wrapper_AU3Check_Parameters= -d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6
#AutoIt3Wrapper_AU3Check_Stop_OnWarning=Y
; *****************************************************************************
; Example 1
; Get the primary group for the current user
; *****************************************************************************
#include <AD.au3>

; Open Connection to the Active Directory
_AD_Open()
If @error Then Exit MsgBox(16, "Active Directory Example Skript", "Function _AD_Open encountered a problem. @error = " & @error & ", @extended = " & @extended)

MsgBox(64, "Active Directory Functions - Example 1", "Primary group for user '" & @UserName & "' is '" & _AD_GetUserPrimaryGroup() & "'")

; Close Connection to the Active Directory
_AD_Close()